# coding:utf8
import pandas as pd
from pyspark.sql import SparkSession
from pyspark.sql.types import StructType, IntegerType, StringType

if __name__ == '__main__':
    # 0. 构建执行环境入口对象SparkSession
    spark = SparkSession.builder.\
        appName("test").\
        master("local[*]").\
        getOrCreate()
    sc = spark.sparkContext

    # 读取csv文件
    df = spark.read.format("csv").\
        option("sep", ",").\
        option("header", True).\
        option("encoding", "utf-8").\
        schema("address STRING, area STRING, price INT").\
        load("rent_v2.csv")

    df.printSchema()
    df.show()
